<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
	function Delete(id)
	{
		if(confirm("确定要删除吗？")) {
			location.href = "fruitAction!delete?fruit.fid=" +id;
		}
	}
	</script>
  </head>
  
  <body>
    <center>
     <form action="fruitAction!findAll" method="post">
    	名称:<input name="fruit.name" />
    	产地：<select name="fruit.product.pid">
						<option value="0">--请选择--</option>
						<c:forEach items="${list2 }" var="i">
							 <option value="${i.fid }">${i.fname }</option>
						 </c:forEach>
					  </select>
					  <input type="submit" value="查询">
    </form>
    	<a href="ProductAction!findAll">添加</a>
    	<table border="1">
    		<tr style="background-color: #abcdef">
    			<td>编号</td>
    			<td>名称</td>
    			<td>价格</td>
    			<td>产地</td>
    			<td>操作</td>
    		</tr>
    		<%-- <c:if test="${list eq null }">
    			<c:redirect url="f!findAll"></c:redirect>
    		</c:if> --%>
    		<c:forEach items="${list }" var="f" varStatus="i">
    		<tr
    			<c:if test="${i.count%2 eq 0 }">
  					style="background-color: #abcdef"
  				</c:if>
    		>
    			<td>${f.fid }</td>
    			<td>${f.fname }</td>
    			<td>${f.fprice }</td>
    			<td>${f.product.pname }</td>
    			<td><a href="fruitAction!toUpdate?fruit.fid=${f.fid}">修改</a>&nbsp;&nbsp;
					<a href="javascript:Delete(${f.fid })">删除</a></td>
    		</tr>
    		</c:forEach>
    	</table>
    </center>
  </body>
</html>
